{extend name="public/layout" /}
{block name="head_css"}
    <link rel="stylesheet" href="/static/index/css/detail_footer.css?v={$version}">
    <link rel="stylesheet" href="/static/index/css/detail_comment.css?v={$version}">
    <link rel="stylesheet" href="/static/index/css/detail_content.css?v={$version}">
    <style>
        body {
            background-color: #fff;
        }
        .content-box .html-wrapper div,.content-box .html-wrapper img,.content-box .html-wrapper table,.content-box .html-wrapper embed,.content-box .html-wrapper object,.content-box .html-wrapper video,.content-box .html-wrapper audio {
            width: auto;
            max-width: auto;
            height: auto;
        }


    </style>
    <link rel="stylesheet" href="/static/index/css/header.css?v={$version}">
{/block}

{block name="main"}
    <div class="container sam-header">
        <div class="back">
            <a href="{:url('index')}">
                <div class="arrow"></div>
            </a>
        </div>
        <div class="name">{$title}</div>
    </div>

    <div class="container content-box">
        <div class="title-line">
            <div class="title">{$vo.title}</div>
            <div class="other">
                <div class="date">{$vo.add_time}</div>
                <div class="icon"></div>
                <div class="read">{$vo.pv}次</div>
            </div>
        </div>
        <div class="html-wrapper">
            {$vo.detail}
        </div>
    </div>

    <div class="container comment-box">
        <div class="item-line">
            <div class="title">用户评价({$vo.comment_num})</div>
            <div class="more">
                <a href="{:url('comment_list',array('id'=>$vo.id))}">查看全部&gt;&gt;&gt;</a>
            </div>
        </div>
        {foreach name="comment_list" item="item"}
            <div class="item-line">
                <div class="tel">{$item.uid}</div>
                <div class="comment-item">
                    {foreach name="item.comment" item="comment"}
                        <div class="citem">{$comment}</div>
                    {/foreach}
                </div>
            </div>
        {/foreach}
    </div>

    <div class="container detail-footer">
        <a onclick="like_action(this)" style="width: 50%" class="like-btn {if condition='$is_like eq 1'}like-btn-like{/if}">
            <div class="icon"></div>
            <div id="like_num">({$vo.like_num})</div>
        </a>
        <a class="comment-btn" style="width: 50%" href="{:url('comment',array('id'=>$vo.id))}">
            <div class="icon"></div>
            <div class="words">我要评论</div>
        </a>
    </div>
{/block}
{block name="footer"}{/block}
{block name="script"}
    <script>
        window.onload = function(){
            var url = '{:url("add_pv")}';
            var d = new Object();
            d.id = {$vo.id};
            d.seed = '{$seed}';
            $.post(url,d,function(){

            });
        }
        function like_action(obj){
            if($(obj).hasClass('like-btn-like')){
                var url = '{:url('unlike')}';
            }else{
                var url = '{:url('like')}'
            }
            var d = new Object();
            d.id = {$vo.id};
            $.post(url,d,function(res){
                if(res.code == 1){
                    $('#like_num').text(res.data.like_num);
                    if($(obj).hasClass('like-btn-like')){
                        $(obj).removeClass('like-btn-like');
                    }else{
                        $(obj).addClass('like-btn-like');
                    }
                }else if(res.code == -2){
                    alert('请先登录');
                    window.location.href = '{:url('/index/login/index')}'
                }else{
                    alert(res.msg);
                }
            })
        }
    </script>
{/block}